package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyCyhShareProtect;
import com.laowang.project.system.service.MyCyhShareProtectService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 分享人保护期Controller
 * 
 * @author laowang
 * @date 2023-12-05
 */
@Api(tags = "分享人保护期接口")
@RestController
@RequestMapping("/shareProtect")
public class MyCyhShareProtectController extends BaseController {
    @Autowired
    private MyCyhShareProtectService myCyhShareProtectService;

    /**
     * 查询分享人保护期列表
     */
    @ApiOperation(value = "查询分享人保护期列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:shareProtect:list')")
    @GetMapping("/list")
    public TableDataInfo list(MyCyhShareProtect myCyhShareProtect) {
        startPage();
        List<MyCyhShareProtect> list = myCyhShareProtectService.selectMyCyhShareProtectList(myCyhShareProtect);
        return getDataTable(list);
    }
    
    /**
     * 导出分享人保护期列表
     */
    @ApiOperation(value = "导出分享人保护期列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:shareProtect:export')")
    @Log(title = "分享人保护期", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyCyhShareProtect myCyhShareProtect) {
        List<MyCyhShareProtect> list = myCyhShareProtectService.selectMyCyhShareProtectList(myCyhShareProtect);
        ExcelUtil<MyCyhShareProtect> util = new ExcelUtil<MyCyhShareProtect>(MyCyhShareProtect.class);
        return util.exportExcel(list, "shareProtect");
    }

    /**
     * 获取分享人保护期详细信息
     */
    @ApiOperation(value = "获取分享人保护期详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:shareProtect:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myCyhShareProtectService.selectMyCyhShareProtectById(id));
    }

    /**
     * 新增分享人保护期
     */
    @ApiOperation(value = "新增分享人保护期",notes = "")
    @PreAuthorize("@ss.hasPermi('my:shareProtect:add')")
    @Log(title = "分享人保护期", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyCyhShareProtect myCyhShareProtect) {
        return toAjax(myCyhShareProtectService.insertMyCyhShareProtect(myCyhShareProtect));
    }

    /**
     * 修改分享人保护期
     */
    @ApiOperation(value = "修改分享人保护期",notes = "")
    @PreAuthorize("@ss.hasPermi('my:shareProtect:edit')")
    @Log(title = "分享人保护期", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyCyhShareProtect myCyhShareProtect) {
        return toAjax(myCyhShareProtectService.updateMyCyhShareProtect(myCyhShareProtect));
    }

    /**
     * 删除分享人保护期
     */
    @ApiOperation(value = "删除分享人保护期",notes = "")
    @PreAuthorize("@ss.hasPermi('my:shareProtect:remove')")
    @Log(title = "分享人保护期", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myCyhShareProtectService.deleteMyCyhShareProtectByIds(ids));
    }
}
